package com.alan.mr;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * 自定义分区（按年分区）
 * Created by Alan on 2017/10/2.
 */
public class FirstPartition extends Partitioner<KeyPair,Text> {

    @Override
    public int getPartition(KeyPair key, Text values, int numPartitions) {
        return (key.getYear() * 127 )% numPartitions;
    }
}
